import store from '@/store/index.js'

export const hasPerm = (el, binding) => {
    const { value } = binding;
    const hasPermission = checkPermission(value);

    if (!hasPermission) {
        el.parentNode && el.parentNode.removeChild(el);
    }
}

// perm sys:user:add
const checkPermission = (perm) => {
    const allPerms = store.state.buttonPerms;
    return allPerms.includes(perm);
}